#ifndef GL_VERTEX_BUFFER
#define GL_VERTEX_BUFFER
#include "../GL/libExt/libExt.h"
#include "VertexArray.h"
#include "Interfaces/IVertexBuffer.h"
#include "Vertex.h"



namespace gname
{
	
class GLVertexBuffer:public IVertexBuffer
{
public:
	
	
	
	GLVertexBuffer(int size,int typeDataSize = sizeof(Vertex),unsigned usage = 0x88E4);

	~GLVertexBuffer();
	
	
	void Alloc (int vertexCount);
	void Resize(int newVertexSize);
	void Clear();

	void SetData( void* vert) ;
	void AddData(void *data,int newSize);

	void Bind();
	void Unbind();

	int GetCountOfVbo() const;
	unsigned GetId() const;
	
	
	bool IsOk();
	bool IsLock();
	void Init();
	
private:
	
	void GenVbo();
	void DeleteVbo();
	void Lock();
	void Unlock();

	//void ApplyVertexAttribs();
	void IncreaseMemory(int newSize);

protected:
	
	
	VertexArray vao;
	
	
	
	float *texData[8];
	
	
	
	unsigned vboId;
	
	
	
	GLuint vertexCount;
	
	GLuint vertexSize;

	unsigned  vboUsage;

	void**vertexStreamData;

	
	
	
	
	
	bool isInit;
	bool Locked;
	int  typeSize;
	int  next;
	

};
};
#endif